# 递归
'''def return_sum(num):
    if num == 1:
        return num
    return num + return_sum(num - 1)

print(return_sum(999))'''

# lanbda表达式
'''def function():
    return 100

print(function)
print(function())

function1 = lambda : 100
print(function1)
print(function1())'''

'''fn0 = lambda : 100
print(fn0())

fn1 = lambda a, b: a + b
print(fn1(1, 2))

fn2 = lambda a, b = 10: a+b
print(fn2(b = 1, a = 13))

fn3 = lambda *args: args
print(fn3(10, 20, 30, 40))

fn4 = lambda a : a
print(fn4("jjjj"))

fn5 = lambda **kwargs : kwargs
print(fn5(name = '叶文杰', age = 20))

fn6 = lambda a, b : a if a > b else b
print(fn6(1000, 2))'''

student = [
    {"name":"tome", "age":20},
    {"name":"jack", "age":30},
    {"name":"rose", "age":60}
]

'''# 升序排列
student.sort(key=lambda x:x["age"])
print(student)

# 降序排列
student.sort(key=lambda x: x["name"], reverse=True)
print(student)'''

# 高阶函数

def sum_num(a, b, f):
    return f(a) + f(b)


print(sum_num(-4, -9.5, round))